package com.lenovo.vod.player;

import android.os.Bundle;
import android.os.StrictMode;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.lenovo.vod.player.setting.SettingFragment;

public class MainActivity extends AppCompatActivity {
    private Engine mEngine;
    private ContentFragment mContentFragment;
    private ControllerFragment mControllerFragment;
    private SettingFragment mSettingFragment;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        mContentFragment = (ContentFragment) getSupportFragmentManager()
                .findFragmentById(R.id.vodplayer_content);
        mControllerFragment = (ControllerFragment) getSupportFragmentManager()
                .findFragmentById(R.id.vodplayer_controller);
        mSettingFragment = (SettingFragment) getSupportFragmentManager()
                .findFragmentById(R.id.vodplayer_setting);


    }

    @Override
    protected void onResume() {
        super.onResume();
        this.mEngine = new Engine(this);
    }

    public Engine getEngine() {
        return mEngine;
    }

    public ContentFragment getContentFragment() {
        return mContentFragment;
    }

    public ControllerFragment getControllerFragment() {
        return mControllerFragment;
    }

    public SettingFragment getSettingFragment() {
        return mSettingFragment;
    }

    private void initInternet() {

        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                .detectDiskReads().detectDiskWrites().detectAll().penaltyLog()
                .build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                .detectLeakedSqlLiteObjects().detectLeakedClosableObjects()
                .penaltyLog().penaltyDeath().build());
    }
}